/**
 * Candidate number: 35834
 */
package tv.starfu.sequencer.gui;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.ControlBuilder;
import de.lessvoid.nifty.builder.ControlDefinitionBuilder;
import de.lessvoid.nifty.builder.EffectBuilder;
import de.lessvoid.nifty.builder.HoverEffectBuilder;
import de.lessvoid.nifty.builder.ImageBuilder;
import de.lessvoid.nifty.builder.PanelBuilder;

/**
 * This class defines the Style and Effects on a PatternStepButton.
 * It also contains a ControlBuilder, for constructing Buttons on the main Screen.
 * @author niadzi
 */
public class PatternStepButtonDefinition {
    private static final String NAME = "PatternStepButtonControl";
    private static final String PARAMETER_STEP = "step";
    private static final String PARAMETER_CHANNEL = "channel";
    private static final String PARAMETER_STATE = "state";
    
    public static void register(final Nifty nifty) {
        new ControlDefinitionBuilder(NAME) {{
            controller(new PatternStepButtonController());
            
            // Design button panel
            panel(new PanelBuilder() {{
            // backgroundImage("Interface/trillian/grass.png");
             width("30px");
             height("30px");
             alignCenter();
             valignCenter();
             childLayoutCenter();
             focusable(true);
             visibleToMouse();
             image(new ImageBuilder() {{
                 filename("Interface/trillian/grass.png");
                 imageMode("subImage:10,10,32,32");
                            }});
             
             
             // Set button Effects
             onActiveEffect(new EffectBuilder("border") {{
                 effectParameter("color", "#112f");
                 }});   // End Effect
             
             onHoverEffect(new HoverEffectBuilder("border") {{
                 effectParameter("color", "#872f");
                 }});   // End Effect

            }}); // End button panel
        
        }}.registerControlDefintion(nifty);
    }
    
    /**
     * Creates a PatternStepButtonControl
     * @param id
     * @param step
     * @param channel
     * @param state
     * @return 
     */
    public static ControlBuilder getControlBuilder(final String id, final String step, final String channel, final String state) {
        return new ControlBuilder(id, NAME) {{
            parameter(PARAMETER_STEP, step);
            parameter(PARAMETER_CHANNEL, channel);
            parameter(PARAMETER_STATE, state);
    }};
        
  }
}
